# import country shapes
africa <- ne_countries(continent = "Africa", returnclass = "sf")
# cause-of-death data
CODAfrica <- read_excel("../Cause of Death AFRICA.xlsx")
# harmonize names in the COD dataset
CODAfrica <- CODAfrica %>%
mutate(Entity = recode(Entity,
"Somaliland" = "Somalia",
"Eswatini" = "eSwatini",
"Cabo Verde" = "Cape Verde",
"GuineaBissau" = "Guinea-Bissau",
"Democratic Republic of Congo" = "Dem. Rep. Congo",
"Cote dIvoire" = "Côte d'Ivoire",
"Equatorial Guinea" = "Eq. Guinea",
"South Sudan" = "S. Sudan",
"Central African Republic" = "Central African Rep."
))
# harmonize names in the spatial data
africa <- africa %>%
mutate(name = recode(name,
"W. Sahara" = "Morocco",
"Somaliland" = "Somalia"
))
# filter 2006 HIV/AIDS fatalities
hiv_2006 <- CODAfrica %>%
filter(Year == 2006) %>%
select(Entity, `HIV/AIDS fatalities`)
# join and check for mismatches
africa_hiv <- africa %>%
left_join(hiv_2006, by = c("name" = "Entity"))
# report unmatched entities from the data file
unmatched <- setdiff(hiv_2006$Entity, africa$name)
if (length(unmatched) > 0) message("Unmatched entities from COD data: ", paste(unmatched, collapse = ", "))
The pitch black colour on the map representing South Africa emphasizes the extreme amount of HIV/AIDS-related fatalities in the country in 2006, which stood at 310,000. This is significantly higher than any other country in Africa for that year, with the next highest being Nigeria at 140,000 fatalities.